package com.game.manager
{
	
	import com.dusk.tool.Calendar;
	import com.dusk.util.RandomUtil;
	import com.game.view.component.notification.AlertBox;
	import com.game.view.component.notification.TipBox;
	
	import config.Config;
	
	import export.huodong.newyear.ChineseNewYear;
	
	import flash.events.Event;
	
	public class NotificationManager
	{
		
		public function NotificationManager()
		{
		}
		
		public static var hasShowWatermark:Boolean = false;
		
		private static var _alertBox:AlertBox;
		
		private static var hasTellPlayer:Boolean = false;
		
		public static function showLoginAlert(... rest):void
		{
			var calendar:Calendar = new Calendar(new Date());
			var tellingBox:TipBox = getNewTipBox("",null,null,true);
			if (!NotificationManager.hasTellPlayer)
			{
				NotificationManager.hasTellPlayer = true;
				var lFtv:String = calendar.getlFtv();
				var sFtv:String = calendar.getsFtv();
				switch (lFtv)
				{
					case "除夕":
						tellingBox.setText("今天是过年了，没想到大家还在玩造梦西游啊~");
						tellingBox.hideBtn();
						break;
					case "春节":
						tellingBox.setText("新年快乐！送你一个小红包吧！");
						tellingBox.setConfirmFunc(ChineseNewYear.getRedPack);
						tellingBox.hideBtn();
						break;
					default:
						tellingBox.setText("欢迎来到\n造梦西游之三界纵横！");
						tellingBox.hideBtn();
				}
				switch (sFtv)
				{
					case "愚人节":
						tellingBox.setText("没有v我50就想玩造梦？");
						tellingBox.hideBtn();
						break;
					case "国庆节 国际音乐节 国际老人节":
						tellingBox.setText("国庆节快乐！");
						tellingBox.hideBtn();
				}
				if (tellingBox)
				{
					tellingBox.add();
				}
			}
		}
		
		public static function tip(content:String = "", confirmFunc:Function = null, cancelFunc:Function = null, displayCancel:Boolean = true):void
		{
			var _tipBox:TipBox = new TipBox(content,confirmFunc,cancelFunc,displayCancel);
			GameSceneManager.getIns().addScene(_tipBox,"top");
		}
		
		public static function alert(content:String, time:int = 1, fontsize:int = 30):void
		{
			if(!_alertBox)
			{
				_alertBox = new AlertBox();
			}
			_alertBox.setTxt(content,time,fontsize);
			GameSceneManager.getIns().addScene(_alertBox,"stage");
		}
		
		public static function getNewTipBox(content:String = "", confirmFunc:Function = null, cancelFunc:Function = null, displayCancel:Boolean = true):TipBox
		{
			var _tipBox:TipBox = new TipBox(content,confirmFunc,cancelFunc,displayCancel);
			return _tipBox;
		}
		
		public static function tellRest(level:int):void
		{
			switch (level)
			{
				case 0:
					tip("您已经游戏很久了\n休息一下吧",null,null,false);
					break;
				case 1:
					tip("您已经游戏很久了\n休息一下吧\n点击确定退出游戏",
						function (evt:Event):void
						{
							Config.getIns().memory.saveGame(Config.getIns().saveId);
							GameSceneManager.getIns().mainStage.nativeWindow.close();
						},null,false);
					break;
			}
		}
		
		public static function tellNotOpen(... rest):void
		{
			const content:Array = [
					"前面的区域，以后再来探索吧",
					"别催啦，马上就来",
					"当前功能开小差了呢",
					"暂未开启",
					"作者秃头开发中"
			];
			const weightArr:Array = [
					10,
					10,
					10,
					1,
					10
			];
			alert(RandomUtil.randSwitch(content,weightArr));
		}
	}
}